/*
 * @Descripttion:
 * @version:
 * @Author: ChenXiang
 * @Date: 2021-04-07 10:55:38
 * @LastEditors: ChenXiang
 * @LastEditTime: 2021-07-12 15:32:40
 */
import React, { useState, useRef, useEffect, useCallback } from "react";
import Picker from "@/hocs/Picker";
import Button from "@/components/Button";

export default (props) => {
  const [visible, setVisible] = useState(false);
  const [current, setCurrent] = useState([]);
  const [data, setData] = useState([
    { text: "cx", value: "cx", check: false },
    { text: "cx1", value: "cx1", check: true },
    { text: "cx2", value: "cx2", check: false },
  ]);
  const onChange = (current, data) => {
    setData(data);
  };
  const reset = () => {
    const init = data.map((item) => {
      item.check = false;
      return item;
    });
    setData(init);
  };
  return (
    <div>
      <p onClick={() => setVisible(true)}>on</p>
      {/* <Picker
        visible={visible}
        onCancel={() => setVisible(false)}
        title={"cx"}
        onChange={onChange}
        footer={[
          <Button key={1} onClick={() => onChange}>确定</Button>,
          <Button key={2} onClick={() => setVisible(false)}>重置</Button>
        ]
        }
      >
        111
      </Picker> */}
      <Picker
        data={data}
        type="checkbox"
        visible={visible}
        onCancel={() => setVisible(false)}
        title={"cx"}
        onChange={onChange}
        footer={[
          <Button
            key={2}
            onClick={() => {
              reset();
            }}
          >
            重置
          </Button>,
          <Button
            key={1}
            onClick={() => {
              console.log(data);
            }}
          >
            确定
          </Button>,
        ]}
      />
    </div>
  );
};
